package com.qyhl.party.party.test;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.gyf.immersionbar.ImmersionBar;
import com.qyhl.party.R;
import com.qyhl.party.R2;
import com.qyhl.webtv.basiclib.base.BaseFragment;
import com.qyhl.webtv.commonlib.constant.ARouterPathConstant;
import com.qyhl.webtv.commonlib.entity.party.PartyUserInfo;

import butterknife.BindView;
import butterknife.OnClick;

public class PartyTestFragment extends BaseFragment{
    @BindView(R2.id.compare_result)
    TextView compareResult;
    @BindView(R2.id.challenge_result)
    TextView challengeResult;

    private String token;

    private String realName;

    private int winCount;

    private int loseCount;

    private int bestCount;

    public void setWinCount(int winCount) {
        this.winCount = winCount;
    }

    public void setLoseCount(int loseCount) {
        this.loseCount = loseCount;
    }

    public void setBestCount(int bestCount) {
        this.bestCount = bestCount;
    }


    public void setToken(String token) {
        this.token = token;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public static PartyTestFragment newInstance(String token, String realName,int bestCount,int loseCount,int winCount) {
        PartyTestFragment fragment = new PartyTestFragment();
        fragment.setToken(token);
        fragment.setRealName(realName);
        fragment.setWinCount(winCount);
        fragment.setLoseCount(loseCount);
        fragment.setBestCount(bestCount);
        return fragment;
    }

    @SuppressLint("InflateParams")
    @Override
    protected View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.party_fragment_test, null);
    }

    @Override
    public void initImmersionBar() {
        ImmersionBar.with(this)
                .statusBarDarkFont(true)
                .titleBar(R.id.title_layout)
                .init();
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void create() {
        challengeResult.setText("最好成绩：" + bestCount + "道");

        compareResult.setText("胜" + winCount + "场，负" + loseCount + "场");
    }

    @Override
    protected void setListener() {

    }

    @Override
    protected void onFirstVisible() {

    }

    @Override
    protected void onVisible() {

    }

    @Override
    protected void onHide() {

    }

    @OnClick({R2.id.compare_btn, R2.id.challenge_btn})
    public void onClick(View view) {
        int viewId = view.getId();
        if (viewId == R.id.compare_btn) {
            ARouter.getInstance()
                    .build(ARouterPathConstant.PARTY_TEST_COMPARE)
                    .withString("token", token)
                    .withString("realName", realName)
                    .withInt("winCount", winCount)
                    .withInt("loseCount", loseCount)
                    .navigation();
        } else if (viewId == R.id.challenge_btn) {
            ARouter.getInstance()
                    .build(ARouterPathConstant.PARTY_TEST_CHALLENGE)
                    .withString("token", token)
                    .withString("realName", realName)
                    .withInt("bestCount", bestCount)
                    .navigation();

        }
    }

}
